/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.code.client2server;

import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.FieldType;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ChengJiLi
 */
public class BasketOrders {
    @Protobuf
    private int basketId;
    @Protobuf
    private int basketTatol;
    @Protobuf(fieldType = FieldType.OBJECT, order=3, required = false)
    private List<NewOrder> orders ;

    public List<NewOrder> getOrders(){
        return orders;
    }
    public BasketOrders(){
        orders=new ArrayList<NewOrder>();
        basketTatol = 0;
    }
            
    public BasketOrders(List<NewOrder> orders){
        this.orders = orders;
        this.basketTatol = orders.size();
    }
    public void AddOrder(NewOrder order){
        orders.add(order);
        this.setBasketTatol(this.getBasketTatol() + 1);
    }
    public void RemoveOrder(NewOrder order){
        this.orders.remove(order);
    }
    public void RemoveOrder(int i){
        this.orders.remove(i);
    }
    public byte[] EnCode(BasketOrders msg) throws IOException{
        Codec<BasketOrders> Lcode = ProtobufProxy.create(BasketOrders.class);
        return Lcode.encode(msg);
    }
    public BasketOrders DeCode(byte[] data) throws IOException{
        Codec<BasketOrders> Lcode = ProtobufProxy.create(BasketOrders.class);
        return Lcode.decode(data);
        
    }

    /**
     * @return the basketId
     */
    public int getBasketId() {
        return basketId;
    }

    /**
     * @param basketId the basketId to set
     */
    public void setBasketId(int basketId) {
        this.basketId = basketId;
    }

    /**
     * @return the basketTatol
     */
    public int getBasketTatol() {
        return basketTatol;
    }

    /**
     * @param basketTatol the basketTatol to set
     */
    public void setBasketTatol(int basketTatol) {
        this.basketTatol = basketTatol;
    }

    /**
     * @param orders the orders to set
     */
    public void setOrders(List<NewOrder> orders) {
        this.orders = orders;
    }

}
